home *** CD-ROM | disk | FTP | other *** search
Text File | 1991-05-01 | 25.9 KB | 943 lines | [TEXT/MPS ] |
- //$P
- //[a-,body+,h-,o=100,r+,rec+,t=4,u+,#+,j=20/57/1$,n-]
- // UFloatWindow.cp
- // Copyright © 1987-1991 by Apple Computer Inc. All rights reserved.
-
- #ifndef __UFLOATWINDOW__
- #include "UFloatWindow.h"
- #endif
-
- #ifndef __GEOMETRY__
- #include <Geometry.h>
- #endif
-
- #ifndef __TOOLUTILS__
- #include <ToolUtils.h>
- #endif
-
- #ifndef __DESK__
- #include <Desk.h>
- #endif
-
- #ifndef __PALETTES__
- #include <Palettes.h>
- #endif
-
- #ifndef __UAPPLICATION__
- #include <UApplication.h>
- #endif
-
- #ifndef __UMACAPPUTILITIES__
- #include <UMacAppUtilities.h>
- #endif
-
- #ifndef __UMACAPPGLOBALS__
- #include <UMacAppGlobals.h>
- #endif
-
- #ifndef __SYSEQU__
- #include <SysEqu.h>
- #endif
-
-
- //--------------------------------------------------------------------------------------------------
- typedef WindowPtr* WindowPtrPtr; // used to access low memory globals
-
- //--------------------------------------------------------------------------------------------------
- const short kTHINKWindowKind = 32700;
- const short kWindoidWDEF = 48; //(16 * 3); // !!! our default windoid WDEF
-
- //--------------------------------------------------------------------------------------------------
- /* The Layer Mgr included as of System 7.0 and AUX 2.0 presents problems with the Window Mgr patches
- we've installed. Specifically, the problems are that when switching in an application that has
- been switched out under MultiFinder, the application's patches are re-installed prior to the
- application's layer being pulled to front. So, the patches are re-installed and then MF calls
- SelectWindow on the application's layer. However, our patches get control and they need to know
- if the windowPtr that SelectWindow has been handed is a real window or a layer. The only way to
- know is to make a call to the Layer Mgr. However, the Layer Mgr interfaces aren't public, so we
- have to make our own interface to the one Layer Mgr call that we need: IsLayer. This problem _may_
- be fixed if MultiFinder is modified so that it pulls the application's layer to the front
- *before* re-installing the application's patches. */
-
- #ifdef __cplusplus
- extern "C"
- {
- #endif
-
- pascal Boolean MAIsLayer(WindowPtr window) = {
- 0x7002, 0xA829};
- #ifdef __cplusplus
- }
- #endif
-
- //--------------------------------------------------------------------------------------------------
- Boolean gUFloatWindowInitialized = FALSE; // declared in header
-
- //--------------------------------------------------------------------------------------------------
- TrapPatch pBringToFrontPatch;
- TrapPatch pDragWindowPatch;
- TrapPatch pSelectWindowPatch;
- TrapPatch pMoveWindowPatch;
- TrapPatch pZoomWindowPatch;
- TrapPatch pShowWindowPatch;
- TrapPatch pShowHidePatch;
- TrapPatch pHiliteWindowPatch;
- TrapPatch pNewDialogPatch;
-
- // GNE patch record to manage window mgr low memory globals
- TrapPatch pGetNextEventPatch;
-
- // private globals needed by window mgr patches
- Boolean pHasLayerMgr; // flag tells us if the Layer Mgr is in
- Boolean pDuringSelectWindow; /* flag to correctly handle re-entrancy
- problems in SelectWindow */
-
- //--------------------------------------------------------------------------------------------------
- #pragma $Push
- #if qTrace
- #pragma $D+
- #endif
-
- #pragma $R-
- #pragma $V-
- #pragma segment MAWindowRes
-
- pascal void FixedSendBehind(WindowPtr window,
- WindowPtr behind,
- Boolean doActivatePalette)
-
- {
- WindowPeek windPeek;
- GrafPtr savePort;
- RgnHandle clobbered;
- Point rgnTopLeft;
-
- // set up
- windPeek = (WindowPeek)window;
- GetPort(savePort);
- SetPort(window);
-
- // create a rgn so that we can figure out what rgn needs to be recalculated
- clobbered = NewRgn(); // …don't call MakeNewRgn from patch
- CopyRgn(window->visRgn, clobbered);
-
- // convert the rgn into globals
- rgnTopLeft = (*clobbered)->rgnBBox[topLeft];
- LocalToGlobal(rgnTopLeft);
- OffsetRgn(clobbered, rgnTopLeft.h - (*clobbered)->rgnBBox.left, rgnTopLeft.v - (*clobbered)->rgnBBox.top);
-
- // put that window where it belongs and activate its palette if requested
- SendBehind(window, behind);
- if ((qNeedsColorQD || gConfiguration.hasColorQD) && doActivatePalette)
- ActivatePalette(window);
-
- // figure out what needs to be painted, paint it, and recalculate vis rgns
- DiffRgn(windPeek->strucRgn, clobbered, clobbered);
- PaintOne(windPeek, clobbered);
- CalcVisBehind(windPeek, clobbered); //windPeek->strucRgn
-
- // clean up
- DisposeRgn(clobbered);
- SetPort(savePort);
- }
- #pragma $Pop
-
- //--------------------------------------------------------------------------------------------------
- #pragma $Push
- #if qTrace
- #pragma $D+
- #endif
-
- #pragma $R-
- #pragma $V-
- #pragma segment MAWindowRes
-
- pascal void CallBringToFront(WindowPtr window,
- long oldTrap) = {
- 0x205F, 0x4E90};
-
- pascal void MABringToFront(WindowPtr window)
-
- // Patch for BringToFront that preserves window layering:
- // • for floaters, leave the routine && call the real BringToFront;
- // • for dialogs, leave the routine && call the real BringToFront;
- // • if no floaters, leave the routine && call the real BringToFront;
- // • otherwise, call SendBehind
-
- {
- long oldA5 = SetCurrentA5();
- WindowPtr lastFloatingWindowPtr;
- WindowPeek windPeek;
- WindowPtr activeWindow;
-
- windPeek = ((WindowPeek)window);
-
- if (IsFloatWindow(window))
- {
- /* • Floaters: call the real BringToFront;*/
- if (gApplication->IsFrontProcess() && (window != FrontWindow()))
- CallBringToFront(window, pBringToFrontPatch.oldTrapAddr);
- }
- else
- {
- if ((pHasLayerMgr && MAIsLayer(window)) || (windPeek->windowKind < 0))
- CallBringToFront(window, pBringToFrontPatch.oldTrapAddr);/* • Layers or System Windows: call
- the real BringToFront;*/
-
- else
- {
- if (IsDialog(window))
- {
- /* • Dialogs: call the real BringToFront and
- then de-hilite and deactivate the active
- window*/
- // bring the dialog to the front
- CallBringToFront(window, pBringToFrontPatch.oldTrapAddr);
-
- // de-hilite the active window and deactivate it
- activeWindow = MAGetActiveWindow();
- if ((activeWindow) && (activeWindow != window))
- {
- HiliteWindow(activeWindow, FALSE);
- *((WindowPtrPtr)CurDeactive) = activeWindow;// set curDeactive
- if (activeWindow)
- *((IntegerPtr)CurDeKind) = ((WindowPeek)activeWindow)->windowKind;
- }
- }
- else
- { /* • Document windows */
- lastFloatingWindowPtr = GetLastFloatingWindowPtr();
- if (!lastFloatingWindowPtr) /* • if no floaters, call the real
- BringToFront*/
- CallBringToFront(window, pBringToFrontPatch.oldTrapAddr);
- else /* • if there are floaters, call SendBehind*/
- {
- SendSystemWindowsToBack();// send system windows to back
- FixedSendBehind(window, lastFloatingWindowPtr, TRUE);
- }
- }
- }
- }
- SetA5(oldA5);
- }
- #pragma $Pop
-
- //--------------------------------------------------------------------------------------------------
- #pragma $Push
- #if qTrace
- #pragma $D+
- #endif
-
- #pragma $R-
- #pragma $V-
- #pragma segment MAWindowRes
-
- pascal void MADragWindow(WindowPtr window,
- Point startPt,
- Rect bounds)
-
- // Complete replacement of DragWindow that preserves window layering.
-
- {
- const short kCommandKey = 55;
-
- long oldA5 = SetCurrentA5();
- GrafPtr wMgrPort;
- GrafPtr savePort;
- RgnHandle dragRgn;
- long result;
- Point newLoc;
- Rect portBounds;
- RgnHandle tempRgn;
- WindowPtr clipWindow;
- Boolean commandFlag;
- KeyMap theKeys;
-
- // set up some parameters
- GetKeys(theKeys);
- commandFlag = BitTst((Ptr)theKeys, kCommandKey);
- if (StillDown())
- {
- GetPort(savePort);
- GetWMgrPort(wMgrPort);
- SetPort(wMgrPort);
-
- tempRgn = NewRgn(); // what if NewRgn returns NULL???
- GetClip(tempRgn);
-
- // drag the gray outline
- if (commandFlag)
- clipWindow = window; // we won't be activating this window
- else if (IsFloatWindow(window) || (((WindowPeek)window)->windowKind < 0))
- clipWindow = FrontWindow(); // floaters && DAs get dragged at front
- else
- {
- SendSystemWindowsToBack(); // send system windows to back
- clipWindow = MAFrontWindow();
- }
- MAClipAbove(clipWindow);
- dragRgn = NewRgn(); // what if NewRgn returns NULL???
- CopyRgn(((WindowPeek)window)->strucRgn, dragRgn);
- result = DragGrayRgn(dragRgn, startPt, bounds, bounds, noConstraint, NULL);
-
- SetClip(tempRgn);
- DisposeRgn(tempRgn);
- DisposeRgn(dragRgn);
-
- // determine what to do with the window
- newLoc.v = HiWord(result);
- newLoc.h = LoWord(result);
- if (newLoc.v == 0x8000)
- {
- // in certain situations, we sent the system windows to back.
- //Since we sent the system windows to back, we need to activate the front
- //window if it is now the front document window.
- if ((!commandFlag) && (!IsFloatWindow(window)) && (((WindowPeek)window)->windowKind >= 0) && (((WindowPeek)window)->windowKind < kTHINKWindowKind))
- SelectWindow(window);
- }
- else
- {
- if ((((CGrafPtr)window)->portVersion & 0xC000) != 0)
- portBounds = (*((CGrafPtr)window)->portPixMap)->bounds;
- else
- portBounds = window->portBits.bounds;
-
- newLoc += window->portRect[topLeft] - portBounds[topLeft];
- MoveWindow(window, newLoc.h, newLoc.v, FALSE);
- if (!commandFlag)
- SelectWindow(window);
- }
-
- // restore various values
- SetPort(savePort);
- }
-
- SetA5(oldA5);
- }
- #pragma $Pop
-
- //--------------------------------------------------------------------------------------------------
- #pragma $Push
- #if qTrace
- #pragma $D+
- #endif
-
- #pragma $R-
- #pragma $V-
- #pragma segment MAWindowRes
-
- WindowPtr pFrontWindow; /* stores the reference to the window that
- the MAFrontWindow patch should return */
- TrapPatch pFrontWindowPatch;
-
- pascal WindowPtr FrontWindowPatch(void) /* patch to FrontWindow that is active while
- calling ActivatePalette */
-
- {
- return pFrontWindow;
- }
-
-
- pascal void MAActivatePalette(WindowPtr window)
- // ensures that the call to ActivatePalette on "window" actually takes effect
-
- {
- Boolean needsFrontWindowPatch;
-
- pFrontWindow = window;
- needsFrontWindowPatch = FrontWindow() != window;
- if (needsFrontWindowPatch) /* patch FrontWindow so that it returns the
- "window" */
- FailOSErr(PatchTrap(pFrontWindowPatch, _FrontWindow, (Ptr) & FrontWindowPatch));
- ActivatePalette(window);
- if (needsFrontWindowPatch)
- UnpatchTrap(pFrontWindowPatch);
- }
-
- #pragma $Pop
-
- //--------------------------------------------------------------------------------------------------
- #pragma $Push
- #if qTrace
- #pragma $D+
- #endif
-
- #pragma $R-
- #pragma $V-
- #pragma segment MAWindowRes
-
- pascal void CallSelectWindow(WindowPtr window,
- long oldTrap) = {
- 0x205F, 0x4E90};
-
- pascal void MASelectWindow(WindowPtr window)
- // Patch for SelectWindow that preserves window layering.
-
- {
- long oldA5 = SetCurrentA5();
- GrafPtr savePort;
- WindowPtr activeWindow;
-
- if (!pDuringSelectWindow)
- {
- if (pHasLayerMgr && MAIsLayer(window))
- CallSelectWindow(window, pSelectWindowPatch.oldTrapAddr);
- else
- {
- GetPort(savePort);
-
- if (IsFloatWindow(window))
- {
- BringToFront(window);
-
- /* for color environments, set the floater's palette to be the active
- palette iff the active window has no palette */
- if (qNeedsColorQD || gConfiguration.hasColorQD)
- {
- activeWindow = MAGetActiveWindow();
- if (!GetPalette(activeWindow))
- ActivatePalette(window);
- }
- }
- else
- {
- // unhilite and deactivate the active document window
- activeWindow = MAGetActiveWindow();
- if ((activeWindow) && (activeWindow != window))
- {
- HiliteWindow(activeWindow, FALSE);
- *((WindowPtrPtr)CurDeactive) = activeWindow;// set curDeactive
- if (activeWindow)
- *((IntegerPtr)CurDeKind) = ((WindowPeek)activeWindow)->windowKind;
- }
-
- // move the window to the correct position, hilite, and activate it
- pDuringSelectWindow = TRUE;
- BringToFront(window);
- pDuringSelectWindow = FALSE;
- HiliteWindow(window, TRUE);
- if (((WindowPeek)window)->visible)
- *((WindowPtrPtr)CurActivate) = window;// set curActivate
-
- if (qNeedsColorQD || gConfiguration.hasColorQD)
- MAActivatePalette(window);
- }
- SetPort(savePort);
- }
- }
- SetA5(oldA5);
- }
- #pragma $Pop
-
- //--------------------------------------------------------------------------------------------------
- #pragma $Push
- #if qTrace
- #pragma $D+
- #endif
-
- #pragma $R-
- #pragma $V-
- #pragma segment MAWindowRes
-
- pascal void CallMoveWindow(WindowPtr theWindow,
- short hGlobal,
- short vGlobal,
- Boolean front,
- long oldTrap) = {
- 0x205F, 0x4E90};
-
- pascal void MAMoveWindow(WindowPtr theWindow,
- short hGlobal,
- short vGlobal,
- Boolean front)
- // Tail Patch for MoveWindow that preserves window layering.
- // We do this b/c MoveWindow doesn't call SelectWindow trap, instead jumps directly there
-
- {
- long oldA5 = SetCurrentA5();
-
- // force FALSE for "front" parameter
- CallMoveWindow(theWindow, hGlobal, vGlobal, FALSE, pMoveWindowPatch.oldTrapAddr);
-
- if (front)
- SelectWindow(theWindow);
- SetA5(oldA5);
- }
- #pragma $Pop
-
- //--------------------------------------------------------------------------------------------------
- #pragma $Push
- #if qTrace
- #pragma $D+
- #endif
-
- #pragma $R-
- #pragma $V-
- #pragma segment MAWindowRes
-
- pascal void CallZoomWindow(WindowPtr theWindow,
- short partCode,
- Boolean front,
- long oldTrap) = {
- 0x205F, 0x4E90};
-
- pascal void MAZoomWindow(WindowPtr theWindow,
- short partCode,
- Boolean front)
-
- {
- long oldA5 = SetCurrentA5();
-
- // force FALSE for "front" parameter
- CallZoomWindow(theWindow, partCode, FALSE, pZoomWindowPatch.oldTrapAddr);
-
- if (front)
- SelectWindow(theWindow);
- SetA5(oldA5);
- }
- #pragma $Pop
-
- //--------------------------------------------------------------------------------------------------
- #pragma $Push
- #if qTrace
- #pragma $N+
- #endif
-
- #pragma $D-
- #pragma $R-
- #pragma $V-
- #pragma segment MAWindowRes
-
- pascal void CallHiliteWindow(WindowPtr theWindow,
- Boolean fHilite,
- long oldTrap) = {
- 0x205F, 0x4E90};
-
- pascal void MAHiliteWindow(WindowPtr theWindow,
- Boolean fHilite)
-
- // Patch to HiliteWindow which ensures that the correct window gets hilited/dehilited
- // during call to NewDialog.
-
- {
- long oldA5 = SetCurrentA5();
- WindowPtr toHilite;
-
- if (((WindowPeek)theWindow)->visible)
- {
- if (!IsFloatWindow(theWindow))
- CallHiliteWindow(theWindow, fHilite, pHiliteWindowPatch.oldTrapAddr);
- else
- {
- if (fHilite)
- {
- toHilite = MAFrontWindow();
- *((WindowPtrPtr)CurActivate) = toHilite;// set curActivate
- }
- else
- {
- toHilite = MAGetActiveWindow();
- *((WindowPtrPtr)CurDeactive) = toHilite;// set CurDeactive
- if (toHilite)
- *((IntegerPtr)CurDeKind) = WindowPeek(toHilite)->windowKind;
- }
- if (toHilite)
- CallHiliteWindow(toHilite, fHilite, pHiliteWindowPatch.oldTrapAddr);
- }
- }
-
- SetA5(oldA5);
- }
- #pragma $Pop
-
- //--------------------------------------------------------------------------------------------------
- #pragma $Push
- #if qTrace
- #pragma $N+
- #endif
-
- #pragma $D-
- #pragma $R-
- #pragma $V-
- #pragma segment MAWindowRes
-
- pascal DialogPtr CallNewDialog(void *wStorage,const Rect& boundsRect,ConstStr255Param title,
- Boolean visible,short procID,WindowPtr behind,Boolean goAwayFlag,long refCon,
- Handle itmLstHndl, long oldTrap) = {0x205F, 0x4E90};
-
- pascal DialogPtr MANewDialog(void *wStorage,const Rect& boundsRect,ConstStr255Param title,
- Boolean visible,short procID,WindowPtr behind,Boolean goAwayFlag,long refCon,
- Handle itmLstHndl)
- {
- long oldA5 = SetCurrentA5();
- Boolean needsHiliteWindowPatch = IsFloatWindow(FrontWindow());
- if (needsHiliteWindowPatch)
- FailOSErr(PatchTrap(pHiliteWindowPatch, _HiliteWindow, (Ptr) & MAHiliteWindow));
- DialogPtr aDialogPtr = CallNewDialog(wStorage, boundsRect, title, visible, procID, behind,
- goAwayFlag, refCon, itmLstHndl, pNewDialogPatch.oldTrapAddr);
- if (needsHiliteWindowPatch)
- UnpatchTrap(pHiliteWindowPatch);
- SetA5(oldA5);
- return aDialogPtr;
- }
-
- #pragma $Pop
-
- //--------------------------------------------------------------------------------------------------
- #pragma $Push
- #if qTrace
- #pragma $D+
- #endif
-
- #pragma $R-
- #pragma $V-
- #pragma segment MAWindowRes
-
- pascal void CallShowWindow(WindowPtr theWindow,
- long oldTrap) = {
- 0x205F, 0x4E90};
-
- pascal void MAShowWindow(WindowPtr theWindow)
- // tail patch to ShowWindow which ensures that SelectWindow gets called for a shown window
-
- {
- long oldA5 = SetCurrentA5();
- if (!WindowPeek(theWindow)->visible)
- {
- CallShowWindow(theWindow, pShowWindowPatch.oldTrapAddr);
- if (MAFrontWindow() == theWindow)
- SelectWindow(theWindow);
- }
- SetA5(oldA5);
- }
- #pragma $Pop
-
- //--------------------------------------------------------------------------------------------------
- #pragma $Push
- #if qTrace
- #pragma $D+
- #endif
-
- #pragma $R-
- #pragma $V-
- #pragma segment MAWindowRes
-
- pascal void CallShowHide(WindowPtr theWindow,
- Boolean showFlag,
- long oldTrap) = {
- 0x205F, 0x4E90};
-
- pascal void MAShowHide(WindowPtr theWindow,
- Boolean showFlag)
-
- // This patch manages the global pActiveWindow, and activates the next document window in the case
- //where we're hiding the currently active document window and there are floaters present.
- //
- // Note that this patch to ShowHide actually gets called from 5 other traps, since:
- //
- // HideWindow calls ShowHide
- // CloseWindow calls ShowHide
- // DisposWindow calls CloseWindow
- // CloseDialog calls CloseWindow
- // DisposDialog calls CloseDialog
- //
- // So, ShowHide is the routine through which all other Window Mgr routines eventually bottleneck to
- //actually hide the window.
-
- {
- long oldA5 = SetCurrentA5();
- Boolean needActivate;
- WindowPtr toActivate;
-
- // if we're hiding a front document window that's not the actual front window (i.e. it's in back
- // of a floater) then we need to select the next document window
- needActivate = (!showFlag) && (theWindow == MAFrontWindow()) && (FrontWindow() != theWindow);
-
- CallShowHide(theWindow, showFlag, pShowHidePatch.oldTrapAddr);
-
- // activate the next window if necessary
- if (needActivate)
- {
- toActivate = MAFrontWindow();
- if (toActivate)
- {
- // instead, call SelectWindow ???
- *((WindowPtrPtr)CurActivate) = toActivate;// set curActivate
- HiliteWindow(toActivate, TRUE);
- }
- }
-
- SetA5(oldA5);
- }
- #pragma $Pop
-
- //--------------------------------------------------------------------------------------------------
- #pragma $Push
- #if qTrace
- #pragma $N+
- #endif
-
- #pragma $D-
- #pragma $R-
- #pragma $V-
- #pragma segment MAWindowRes
-
- pascal Boolean CallGetNextEvent(short eventMask,
- EventRecord& theEvent,
- long oldTrap) = {
- 0x205F, 0x4E90};
-
- pascal Boolean MAGetNextEvent(short eventMask,
- EventRecord& theEvent)
-
- // tail patch to GetNextEvent that:
- // • redirects activate events from floating windows to front doc window
- // • redirects deactivate events from floating windows to front doc window
-
- {
- long oldA5 = SetCurrentA5();
- WindowPtr myToActivate;
- Boolean result;
-
- result = CallGetNextEvent(eventMask, theEvent, pGetNextEventPatch.oldTrapAddr);
-
- switch (theEvent.what)
- {
- case activateEvt:
- if ((theEvent.modifiers & 1) == 1) // • activate event
- {
- // redirect all activate calls from float windows to the front, non-floater window
- if (IsFloatWindow((WindowPtr)theEvent.message))
- {
- myToActivate = MAFrontWindow();// the front, non-floater window
- if (!myToActivate)
- theEvent.what = nullEvent;// …then zap the activate event!
- else
- {
- HiliteWindow(myToActivate, TRUE);// restore hiliting
- theEvent.message = (long)myToActivate;// redirect activate event
- }
- }
- }
- else // • deactivate event
- // redirect all deactivate calls from float windows to the active window
- if (IsFloatWindow((WindowPtr)theEvent.message))// if deactivate evt is for floater
- theEvent.what = nullEvent; // …then zap the deactivate event!
- break;
- case osEvt:
- if (((theEvent.message & osEvtMessageMask) >> 24) == suspendResumeMessage)
- {
- myToActivate = MAFrontWindow(); // the front, non-floater window
- if (myToActivate)
- HiliteWindow(myToActivate, (theEvent.message & 1) == 1);// switching in/out
- }
- break;
- } // switch what
-
- SetA5(oldA5);
- return result;
- }
- #pragma $Pop
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAOpen
-
- pascal void TFloatWindow::IFloatWindow(TDocument* itsDocument,
- WindowPtr itsWMgrWindow,
- Boolean canResize,
- Boolean canClose,
- Boolean disposeOnFree)
-
- {
- Point saveStdWTopleft;
-
- saveStdWTopleft = gStdWSizeRect[topLeft];
- gStdWSizeRect[topLeft] = gZeroPt;
- this->IWindow(itsDocument, itsWMgrWindow, canResize, canClose, disposeOnFree);
- gStdWSizeRect[topLeft] = saveStdWTopleft;
-
- fHideOnSuspend = TRUE;
- fDoFirstClick = TRUE;
- fFloats = TRUE;
- ((WindowPeek)itsWMgrWindow)->windowKind = kFloatWindowKind;// mark it as a floating window
- fGenerateActivates = FALSE;
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAOpen
-
- pascal void TFloatWindow::IRes(TDocument* itsDocument,
- TView* itsSuperView,
- Ptr& itsParams)
-
- {
- Point saveStdWTopleft;
-
- saveStdWTopleft = gStdWSizeRect[topLeft];
- gStdWSizeRect[topLeft] = gZeroPt;
- inherited::IRes(itsDocument, itsSuperView, itsParams);
- gStdWSizeRect[topLeft] = saveStdWTopleft;
-
- fHideOnSuspend = TRUE;
- fDoFirstClick = TRUE;
- fFloats = TRUE;
- ((WindowPeek)fWMgrWindow)->windowKind = kFloatWindowKind;// mark it as a floating window
- fGenerateActivates = FALSE;
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAOpen
-
- pascal WindowPtr TFloatWindow::GetBehindWindowPtr(void)
-
- {
- return (WindowPtr) - 1; // bring the float window up in front of all
- // other windows
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAOpen
- pascal TEvtHandler* TFloatWindow::GetNextHandler(void)// override
-
- {
- return inherited::GetNextHandler();
- /*
- TWindow activeWindow;
- activeWindow = gApplication->GetActiveWindow();
- if (activeWindow)
- return activeWindow.GetTarget();
- else
- return gApplication;
- */
- }
-
- //--------------------------------------------------------------------------------------------------
- #pragma $Push
- #if qTrace
- #pragma $D+
- #endif
-
- #pragma $R-
- #pragma $V-
- // called from patches
- #pragma segment MAWindowRes
-
- pascal void MAClipAbove(WindowPtr window)
- // fixes ROM anomaly in which ClipAbove clips to the current clip rgn.
- // we assume the current port is the window mgr port
-
- {
- SetClip(GetGrayRgn());
- ClipAbove((WindowPeek)window);
- }
- #pragma $Pop
-
- //--------------------------------------------------------------------------------------------------
- #pragma $Push
- #if qTrace
- #pragma $D+
- #endif
-
- #pragma $R-
- #pragma $V-
- #pragma segment MAWindowRes
-
- pascal void DeactivateSystemWindow(WindowPtr window)
- // dehilite && deactivate hilited system windows
-
- {
- WindowPtr cacheActivate;
- EventRecord theEvent;
-
- if (((WindowPeek)window)->hilited)
- {
- // save CurActivate so that EventAvail gives us the Deactivate event
- cacheActivate = *((WindowPtrPtr)CurActivate);
- *((WindowPtrPtr)CurActivate) = NULL;
-
- // de-hilite the system window
- HiliteWindow(window, FALSE);
-
- // process the deactivate event
- *((WindowPtrPtr)CurDeactive) = window; // set curDeactive
- *((IntegerPtr)CurDeKind) = ((WindowPeek)window)->windowKind;
- if (EventAvail(activMask, theEvent)) // gimme that deactivate!
- if ((theEvent.what == activateEvt) && ((theEvent.modifiers & 1) != 1) && (((WindowPtr)theEvent.message) == window) && SystemEvent(theEvent))
- *((WindowPtrPtr)CurDeactive) = NULL;// zap it, it got handled
-
- // restore CurActivate
- *((WindowPtrPtr)CurActivate) = cacheActivate;
- }
- }
-
-
- pascal void SendSystemWindowsToBack(void)
- // send system windows behind all windows
-
- {
- WindowPeek nextWindow;
- WindowPeek thisWindow;
- WindowPeek lastWindow;
- short itsWindowKind;
-
- // find out which non-system window is the last window
- lastWindow = (WindowPeek)FrontWindow();
- CWMgrIterator iter;
-
- for (thisWindow = (WindowPeek)iter.FirstWMgrWindow(); iter.More(); thisWindow = (WindowPeek)iter.NextWMgrWindow())
- {
- itsWindowKind = ((WindowPeek)thisWindow)->windowKind;
- if ((itsWindowKind >= 0) && (itsWindowKind < kTHINKWindowKind))
- lastWindow = thisWindow;
- }
-
-
- // iterate until no more windows or we've reached the last window
- thisWindow = (WindowPeek)FrontWindow();
- while ((thisWindow) && (thisWindow != lastWindow))
- {
- nextWindow = thisWindow->nextWindow; /* what is it *NOW* before we munge the
- window list */
- if (thisWindow->windowKind < 0) // if it's a System window
- {
- FixedSendBehind((WindowPtr)thisWindow, NULL, FALSE);// send thisWindow to back
- DeactivateSystemWindow((WindowPtr)thisWindow);
- }
- thisWindow = nextWindow;
- }
- }
- #pragma $Pop
-
- //--------------------------------------------------------------------------------------------------
- #pragma segment MAInit
-
- pascal void InitUFloatWindow(void)
-
- {
- if (qTemplateViews && gDeadStripSuppression)
- DontDeadStrip(TFloatWindow); // So the linker doesn't dead strip these
-
- // install window mgr patches
- FailOSErr(PatchTrap(pBringToFrontPatch, _BringToFront, (Ptr) & MABringToFront));
- FailOSErr(PatchTrap(pDragWindowPatch, _DragWindow, (Ptr) & MADragWindow));
- FailOSErr(PatchTrap(pSelectWindowPatch, _SelectWindow, (Ptr) & MASelectWindow));
- FailOSErr(PatchTrap(pMoveWindowPatch, _MoveWindow, (Ptr) & MAMoveWindow));
- FailOSErr(PatchTrap(pZoomWindowPatch, _ZoomWindow, (Ptr) & MAZoomWindow));
- FailOSErr(PatchTrap(pShowWindowPatch, _ShowWindow, (Ptr) & MAShowWindow));
- FailOSErr(PatchTrap(pShowHidePatch, _ShowHide, (Ptr) & MAShowHide));
-
- // Only patch _HiliteWindow if called from NewDialog or from CloseDialog
- //FailOSErr(PatchTrap(pHiliteWindowPatch, _HiliteWindow, (Ptr) & MAHiliteWindow));
- FailOSErr(PatchTrap(pNewDialogPatch, _NewDialog, (Ptr) & MANewDialog));
-
- // tail patch to GNE which redirects activate/deactivate events
- FailOSErr(PatchTrap(pGetNextEventPatch, _GetNextEvent, (Ptr) & MAGetNextEvent));
-
- // !!! no constant since as of System 7 this trap is still private
- pHasLayerMgr = TrapExists(0xA829);
-
- pDuringSelectWindow = FALSE;
- gUFloatWindowInitialized = TRUE;
- }
-
-
-